﻿Clear-Host
$ServerInstance= "DC1-vp-DBAdmin"
$HostName= $ServerInstance.Split("\")[0];

$cn= New-Object System.Data.SqlClient.SQLConnection("Data Source=$ServerInstance;Integrated Security=SSPI"); $cn.Open();
$cmd= New-Object System.Data.SqlClient.SqlCommand("SELECT master.DBAdmin.GetInstancePath(N'SQLDataRoot') AS SQLDataRoot;", $cn);

$r= $cmd.ExecuteReader([System.Data.CommandBehavior]::CloseConnection);
if ($r.read()) {$Cache= "$($r[0])MDWCache"};
$r.Close(); $cn.Close();
$Cache